from strategy_mode import dataLoader, str_cal, Trading, TradingRules

# 上涨模式
def UpMode(
    df_day, df_day_1, preTYPES, mode, tradePersent, day_lists, day, statsdic, count_in
):

    return mode, tradePersent


# 下跌模式
def DownMode(
    df_day, df_day_1, preTYPES, mode, tradePersent, day_lists, day, statsdic, count_in
):

    return mode, tradePersent


def RoundMode(
    df_day, df_day_1, preTYPES, mode, tradePersent, day_lists, day, statsdic, count_in
):

    return mode, tradePersent


def Main(
    df_day,
    df_day_1,
    mode="BUY/SELL",
    line_Pares=5,
    tradePersent=1,
    day_lists=[],
    day=0,
    statsdic={},
    count_in=1,
):

    types = statsdic["TYPES"]
    tradePersent = 0
    for col in df_day.index.tolist():
        if "All_by%_sum" in col and "All" in col:
            if "TH_" in col:
                sum_up = col
            elif "TL_" in col:
                sum_low = col
            else:
                sum_All = col

    if df_day[sum_All] < df_day_1[sum_All]:
        types = "LOW"

    elif df_day[sum_All] > df_day_1[sum_All]:  # 上涨模式
        types = "HIGH"

    # TODO 增加循环判断节,解决连续下跌止损问题
    if df_day_1[sum_low] < df_day_1[sum_All] and df_day[sum_low] > df_day[sum_All]:
        mode = "SELL"
        tradePersent = 0.5

    elif df_day_1[sum_up] < df_day_1[sum_All] and df_day[sum_up] > df_day[sum_All]:
        mode = "BUY"
        tradePersent = 0.5

    statsdic["TYPES"] = types
    return mode, tradePersent, statsdic
